<template>
    <div class="home_aside">
        <el-menu default-active="1-4-1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose"
            :collapse="isCollapse" text-color="#F6F5F7" active-text-color="#E0B94C" background-color="#1A225A"
            :router="true">
            <!-- 
                :route=true 是开启该导航的route跳转功能，注意，使用route跳转路由，index必须写，哪怕是空串
                其实直接使用index，在index='路由地址'也是可以跳转路由的
            -->
            <el-menu-item :route="{ name: 'homeitem' }" index="">
                <i class="el-icon-setting"></i>
                <span slot="title">首页</span>
            </el-menu-item>

            <el-submenu index="用户管理">
                <template slot="title">
                    <i class="el-icon-user-solid"></i>
                    <span>用户管理</span>
                </template>
                <el-menu-item-group>
                    <el-menu-item :route="{ name: 'userManagement' }" index="管理员">
                        管理员
                    </el-menu-item>
                    <el-menu-item :route="{ name: 'student' }" index="学员管理">
                        学员管理
                    </el-menu-item>
                </el-menu-item-group>
            </el-submenu>

            <el-submenu index="课程管理">
                <template slot="title">
                    <i class="el-icon-notebook-1"></i>
                    <span>课程管理</span>
                </template>
                <el-menu-item-group>
                    <el-menu-item :route="{ name: 'courseAdd' }" index="课程添加">课程添加</el-menu-item>
                    <el-menu-item :route="{ name: 'courseList' }" index="课程列表">课程列表</el-menu-item>
                    <el-menu-item :route="{ name: 'videoMode' }" index="视频模块">视频模块</el-menu-item>
                </el-menu-item-group>
            </el-submenu>
        </el-menu>
    </div>
</template>

<script>
import { Menu, Submenu, MenuItemGroup, MenuItem } from 'element-ui';
export default {
    components: {

        "el-menu": Menu,
        "el-menu-item": MenuItem,
        "el-menu-item-group": MenuItemGroup,
        "el-submenu": Submenu,
        // "el-radio-group":RadioGroup,
        // "el-radio-button":RadioButton
    },
    data() {
        return {
            isCollapse: true
        };
    },
    methods: {
        handleOpen(key, keyPath) {
            console.log(key, keyPath);
        },
        handleClose(key, keyPath) {
            console.log(key, keyPath);
        }
    },
    mounted() {
        var that = this
        this.$eventBus.$off('changeIsCollapse1');
        //通过面包屑传过来的isCollpase的布尔值，决定侧边导航栏的展开还是关闭
        this.$eventBus.$on('changeIsCollapse1', (msg) => {
            console.log(msg)
            that.isCollapse = msg
        })
    }
}
</script>

<style lang="less" scoped></style>